<?php

namespace app\topics\middle;

class NodeMiddle extends \app\base\middle\BaseMiddle {


    protected function meta() {
        $this->setMeta('节点');
        $this->setName('节点');
        $this->setCrumb([
            [
                'name' => '节点',
                'url' => url()
            ]
        ]);

        return $this->run([
            'pageInfo' => $this->pageInfo
        ]);
    }

    protected function data() {
        $nodeList = target('topics/TopicsNode')->nodeList();
        foreach ($nodeList as $key => $vo) {
            if($vo['node']) {
                foreach ($vo['node'] as $k => $node) {
                    if($node['moderator']) {
                        $userList = target('topics/TopicsUser')->loadList([
                            '_sql' => 'A.user_id in ('.$node['moderator'].')'
                        ]);
                        foreach ($userList as $user) {
                            $nodeList[$key]['node'][$k]['moderator_list'][] = $user;
                        }
                    }
                }
            }
        }
        return $this->run([
            'pageList' => $nodeList,
        ]);
    }


}